package com.xyz.study.design_mode.k_composite;

import com.xyz.study.design_mode.k_composite.mode.Directory;
import com.xyz.study.design_mode.k_composite.mode.File;

/**
 * 一致性模式：其一 ---- 复合（组合）模式
 * 角色：Client
 * 容器和内容当做一种东西看待，即
 * 能够使容器与内容具有一致性，创造出递归结构的设计模式
 * @author XYZ
 * @version 1.0.0
 * @since 2020/6/22
 */
public class CompositeMain {

    public static void main(String[] args) {
        Directory root = new Directory("root");
        File rootFile = new File("根目录文件", 100);
        Directory rootDirectory = new Directory("一级目录");
        File oneFile = new File("一级目录文件", 100);
        rootDirectory.add(oneFile);
        root.add(rootFile);
        root.add(rootDirectory);
        System.out.println(root.getSize());
    }
}
